function transData(data) {
    var reData;
    data = data + '';
    if(data.length > 4) {
        if(data.indexOf('.') == -1 || data > 10000) {
            var floatData = parseFloat(data) / 10000 + '';
            //console.log(floatData.indexOf('.'))
            if(floatData.indexOf('.') > -1) {
                reData = parseFloat(floatData).toFixed(1) + '万';
            } else {
                reData = floatData + '万';
            }
        } else {
            reData = data;
        }
    } else {
        reData = data;
    }
    // console.log(reData)
    return reData;
}
function addSplit(num){
    var str = num.toString();
    var reg = str.indexOf(".") > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
    return str.replace(reg,"$1,");
}
function addSplit2(data) {
    var val;
    var str = data + '';
   // console.log(str);
    if(str.length > 3){
       if(str.indexOf('.') > 3){
            var ind = str.indexOf('.');
            var arr = str.split('');
            var num = ind-3;
            console.log(num);
            arr.splice(num,0,',');
            val =  arr.join('');
        }else if(str.indexOf('.') <0 ){
            var arr = str.split('');
            arr.splice(arr.length-3,0,',');
            val =  arr.join('');
        }else{
           val = data;
       }
        //console.log(val)
   }else{
        val = data;
    }
    //console.log(val);
    return val;
}
function calPercent(tNowData,yNowData) {
    Number.prototype.toFixed = function (s) {
        var times = Math.pow(10, s);
        var des = this * times + 0.5;
        des = parseInt(des, 10) / times;
        return des;
    };
    var percent;
    var perType;
   // console.log(tNowData + '    ' + yNowData);
    if(tNowData && yNowData && (tNowData != '0' && yNowData!='0')){
        //console.log(111)
        perType = parseFloat(tNowData) > parseFloat(yNowData)? 1 : 2;
        if(perType == 1){
            percent = parseFloat(((parseFloat(tNowData) - parseFloat(yNowData))/parseFloat(yNowData))*100).toFixed(2) +'%';
        }else{
            percent = parseFloat(((parseFloat(yNowData) - parseFloat(tNowData))/parseFloat(yNowData))*100).toFixed(2) +'%';
        }
    }else if(tNowData && yNowData == 0 && tNowData != '0'){
       // console.log(2222)
        perType = 1;
        percent = '100%';
    }else if(tNowData == 0){
        //console.log(333)
        perType = 2;
        percent = '同比: 0%';
    }else{
        percent = '暂无同比';
    }
   // console.log(percent);
    return obj = {
        percent:percent,
        perType:perType
    };
}